home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / bytesc88.arc / ATOIB.C < prev    next >
Text File  |  1987-10-04  |  512b  |  20 lines

  1. #define NOCCARGC  /* no argument count passing */
  2. /*
  3. ** atoib(s,b) - Convert s to "unsigned" integer in base b.
  4. **              NOTE: This is a non-standard function.
  5. */
  6. atoib(s, b) char *s; int b; {
  7.   int n, digit;
  8.   n = 0;
  9.   while(isspace(*s)) ++s;
  10.   while((digit = (127 & *s++)) >= '0') {
  11.     if(digit >= 'a')      digit -= 87;
  12.     else if(digit >= 'A') digit -= 55;
  13.     else                  digit -= '0';
  14.     if(digit >= b) break;
  15.     n = b * n + digit;
  16.     }
  17.   return (n);
  18.   }
  19.  
  20.